//
//  NextViewController.m
//  mhome
//
//  Created by YaSha_Tom on 2018/12/1.
//  Copyright © 2018年 刘春雷. All rights reserved.
//

#import "NextViewController.h"
#import "AppDelegate.h"
#import "TextFileld.h"

@interface NextViewController ()
@property (nonatomic,strong) TextFileld *nameFile;
@property (nonatomic,strong) TextFileld *pwdFile;
@property (nonatomic,strong) TextFileld *okPwdFile;
@property (nonatomic,strong) UIButton *registerBtn;
@property (nonatomic,copy) NSString *nePassword;//新的密码
@property (nonatomic,copy) NSString *oldPassword;//旧的密码)

@end

@implementation NextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"设置密码";
    self.nameFile=[[TextFileld alloc] initWithFrame:CGRects(30, 30, 315, 40)];
//    self.nameFile.text=_user;
    self.nameFile.userInteractionEnabled=NO;
    self.nameFile.backgroundColor=[UIColor whiteColor];
    [self.nameFile.layer setCornerRadius:5.0];
    [self.view addSubview:self.nameFile];
    self.pwdFile=[[TextFileld alloc] initWithFrame:CGRects(30, 90, 315, 40)];
    self.pwdFile.backgroundColor=[UIColor whiteColor];
    self.pwdFile.placeholder=@"密码";
    [self.pwdFile.layer setCornerRadius:5.0];
    self.pwdFile.secureTextEntry = YES;//是否以密码形式显示
    self.pwdFile.clearButtonMode = UITextFieldViewModeWhileEditing;
    [self.pwdFile addTarget:self action:@ selector(paassworkEvent:) forControlEvents:UIControlEventEditingChanged];//监听是否有文本输入
    [self.view addSubview:self.pwdFile];
    self.okPwdFile=[[TextFileld alloc] initWithFrame:CGRects(30, 150, 315, 40)];
    self.okPwdFile.backgroundColor=[UIColor whiteColor];
    self.okPwdFile.placeholder=@"确认密码";
    self.okPwdFile.secureTextEntry = YES;//是否以密码形式显示
    [self.okPwdFile.layer setCornerRadius:5.0];
    self.okPwdFile.clearButtonMode = UITextFieldViewModeWhileEditing;
    [self.okPwdFile addTarget:self action:@ selector(okPassworkEvent:) forControlEvents:UIControlEventEditingChanged];//监听是否有文本输入
    [self.view addSubview:self.okPwdFile];
}

-(void)paassworkEvent:(UITextField*)newPasswork{
    self.nePassword = newPasswork.text;
}
-(void)okpass:(UITextField*)okPasswork{
    self.oldPassword = okPasswork.text;
}
- (void)finish {
    NSString *urlString = [NSString stringWithFormat:@"%@%@",Domain,findPwdApi];
    NSDictionary *dic = @{@"mobile":@"",@"pwd":self.nePassword};
    [[NetworkManager manager] sendPostRequestWithUrl:urlString paramenters:dic success:^(id responseObject) {
        NSLog(@"成功%@",responseObject);
        if([responseObject[@"code"]  isEqual: @1]){
            AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
            [delegate enterTabBarController];
        }else{
            [QMUITips showInfo:responseObject[@"msg"] inView:self.view hideAfterDelay:1];
        }
        
    } failure:^(NSError *error) {
        NSLog(@"失败%@",error);
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
